package com.example.springboot.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableKnife4j
public class WebAPID {
    @Bean
    public Docket buildDocket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .apiInfo(apiInfo())
                .select()
                //Controller所在路径
                .apis(RequestHandlerSelectors.basePackage("com.example.springboot"))
                .paths(PathSelectors.any())
                .build();
    }
    public ApiInfo apiInfo() {
        Contact contact = new Contact("枫恒","https://blog.csdn.net/yy_wzh","2766521760@qq.com");
        return  new ApiInfoBuilder()
                .title("在线教育系统接口api")
                .description("这是在线教育系统的后端部分")
                .termsOfServiceUrl("http://127.0.0.1")
                .contact(contact)
                .version("0.0.1")
                .build();

    }
}
